package com.thx.app.remote.impl;


import org.springframework.beans.BeanUtils;

import mixedserver.protocol.RPCException;
import mixedserver.protocol.jsonrpc.client.Client;

import com.thx.app.remote.CappSoftInterface;
import com.thx.app.remote.model.CappSoft_;
import com.thx.appserver.service.CappSoftManager;
import com.thx.common.spring.BeanFactory;

public class CappSoftImp implements CappSoftInterface{


	public CappSoft_ getNewVersion()  throws RPCException{
		
		CappSoftManager csm = (CappSoftManager) BeanFactory.getBean(CappSoftManager.class);
		com.thx.appserver.model.CappSoft cs = csm.getNewCappSoft();
		CappSoft_ capps = new CappSoft_();
		if(cs != null){
			BeanUtils.copyProperties(cs, capps);
			return capps;
		}
		return null;
		
	/*	boolean flag=false;
		SoftTestMobileManager softTestMobileManager=(SoftTestMobileManager) BeanFactory.getBean("softTestMobileManager");
	
		CappSoftManager cappSoftManager=(CappSoftManager) BeanFactory.getBean("cappSoftManager");
		CappSoftVersionManager cappSoftVersionManager=(CappSoftVersionManager) BeanFactory.getBean("cappSoftVersionManager");
		CappSoft_ result=new CappSoft_();
		CappSoftVersion  version=null;
		if(flag){//可以请求到测试版本
			  version=cappSoftVersionManager.getHighTestVersion(cappSoft.getSoftId());
		}else{
			  version=cappSoftVersionManager.getHighReleaseVersion(cappSoft.getSoftId());
		}
		result.setVerCode(version.getVerCode());
		result.setVerName(version.getVerName());
		result.setVerPath(version.getVerPath());
		result.setVerRelease(version.getVerRelease());
		result.setAppName(version.getAppName());
		return result;*/
	}
	public static void main(String[] args) {
		Client client = Client
				.getClient("http://localhost:8080/thx-web-simple/JSON-RPC?debug=true");
		client.setDencryptMessage(true);
		CappSoftInterface inter = client.openProxy("softUpdate",
				CappSoftInterface.class);
		try {
			CappSoft_ soft=	inter.getNewVersion();
			if(soft!=null){
				System.out.println(soft.getVerCode());
			}
		
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
